<!--
 * @Author: 赵成刚-封装select
-->
<template>
  <view>
    <u-input
      v-model="valuelabel"
      :type="type"
      :border="border"
      clearable
      @click="show = true"
      placeholder="请选择"
      :disabled="disabled"
    />
    <u-select
      v-model="show"
      :list="list"
      @confirm="changFn"
      @cancel="changFn"
    ></u-select>
  </view>
</template>

<script>
export default {
  name: 'C_select',
  props: {
    value: {
      type: String || Number,
    },
    type: {
      type: String,
      default: 'select',
    },
    border: {
      type: Boolean,
      default: false,
    },
    disabled: {
      type: Boolean,
      default: false,
    },
    list: {
      type: Array,
      default: () => {
        return []
      },
    },
    keys: {
      type: String,
    },
    obj: {
      type: Object,
      default: () => {
        return {}
      },
    },
  },
  data() {
    return {
      show: false,
      valuelabel: '',
    }
  },
  methods: {
    changFn(e) {
      let that = this
      that.valuelabel = e[0].label
      that.obj[that.keys] = e[0].value
    },
  },
  mounted() {
    if (this.value) {
      this.valuelabel = this.list.filter((i) => i.value == this.value)[0].label
    }
  },
}
</script>

<style lang="scss">
.navbar-right {
  margin-right: 24rpx;
  float: right;
  position: absolute;
  right: 0;
}
</style>
